<!-- 登录页 -->
<template>
  <div class="login-page">
    <div class="login-container">
      <div class="login-title">登录</div>
      <el-form
        ref="formRef"
        :model="form"
        :rules="rules"
        label-width="80px"
        class="login-form"
      >
        <el-form-item label="手机号" prop="username">
          <el-input v-model="form.username" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="验证码" prop="password">
          <el-input v-model="form.password" type="password" placeholder="请输入验证码" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" class="login-button" @click="handleLogin">
            登录
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();
const form = ref({
  username: '',
  password: '',
});
const rules = ref({
  username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
  password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
});
const handleLogin = () => {
  localStorage.setItem('token_vite_vue3', 'test123456');
  router.push('/home');
};
onMounted(() => {
  console.log('login');
});
</script>
<style lang="scss" scoped>
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100%;
  background-color: #f5f5f5;
  font-family: Arial, sans-serif;

  .login-container {
    width: 400px;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);

    .login-title {
      text-align: center;
      margin-bottom: 20px;
      color: #333;
    }

    .login-form {
      .login-button {
        width: 100%;
      }
    }
  }
}
</style>
